//
//  ThirdLoginAddTelNet.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/8/26.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "ThirdLoginAddTelNet.h"
#import "BLHeader.h"
#import "BasicNetManager.h"

@implementation ThirdLoginAddTelNet

+ (void)getCode:(NSString *)tel completer:(void (^)(id object, NSError *error))completer {
    NSDictionary *dic = @{@"userTel" : tel};
    BasicNetManager *manager = [BasicNetManager share];
    NSInteger loginWay = [[[NSUserDefaults standardUserDefaults] objectForKey:LOGINWAY] integerValue];
    NSString *url;
    switch (loginWay) {
        case 1:
            url = FIRSTWECHATLOGINCODE;
            break;
        case 2:
            url = FIRSTQQLOGINCODE;
            break;
        case 3:
            url = FIRSTWEIBOLOGINCODE;
            break;
        default:
            break;
    }
    [manager postURL:url param:dic completer:^(id result, NSError *error) {
        if (completer) {
            completer(result, error);
        }
    }];
}


+ (void)postNewInfo:(NSDictionary *)param completer:(void(^)(id resultObject, NSError *error))completer {
    BasicNetManager *manager = [BasicNetManager share];
    NSInteger loginWay = [[[NSUserDefaults standardUserDefaults] objectForKey:LOGINWAY] integerValue];
    NSString *url;
    switch (loginWay) {
        case 1:
            url = FIRSTWECHATLOGINADDINFO;
            break;
        case 2:
            url = FIRSTQQLOGINADDINFO;
            break;
        case 3:
            url = FIRSTWEIBOLOGINADDINFO;
            break;
        default:
            break;
    }
   // NSLog(@"url = %@",url);
    [manager postURL:url param:param completer:^(id result, NSError *error) {
        if(completer) {
            if (result) {
                NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
                [userDefault setObject:[result objectForKey:@"userTel"] forKey:USERTEL];
                [userDefault setObject:[result objectForKey:@"userClass"] forKey:USERCLASS];
                [userDefault synchronize];
            }
            completer(result, error);
        }
    }];
}
@end
